<?php
require_once "managerSession.php";
$Item="提现管理";
if(isset($_REQUEST["withdrawDone"])){
    $id=$_REQUEST["withdrawDone"];
    $withdraw=$core->GetUserWithdrawById($id);
    $userId=$withdraw["user_id"];
    $user=$core->GetUserById($userId);
    $result=$core->UpdateWithdraw($userId, $id);
    echo $result;
}
$search="";
$arr=[];
if (isset($_REQUEST["search"])&&!empty($search=trim($_REQUEST["search"]))){
    $arr=$core->GetNormalWithdraw($search);
}else{
    $arr=$core->GetNormalWithdraw();
}

?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>娱乐会所吧台管理系统</title>
    <?php include_once "link.php"; ?>
</head>
<body class="container">
<?php require_once "Nav.php"; ?>
<div class="main">
    <?php include_once "menu.php"; ?>
    <div class="pr inlb bd col-xs-10">
        <table class="table table-striped">
            <caption>
                提现管理
                <form id="search" class="pull-right" action="">
                    <input type="text" name="search" value="<?php echo $search; ?>">
                    <button>搜索</button>
                </form>
            </caption>
            <tr>
                <th>姓名</th>
                <th>手机</th>
                <th>微信</th>
                <th>剩余佣金</th>
                <th>提现金额</th>
                <th>时间</th>
                <th>操作</th>
            </tr>
            <?php

            for($i=0;$i<count($arr);++$i){
            ?>
            <tr>
                <td><?php echo $arr[$i]["name"]; ?></td>
                <td><?php echo $arr[$i]["phone"]; ?></td>
                <td><?php echo $arr[$i]["weixin_Id"]; ?></td>
                <td><?php echo $arr[$i]["remain_bonus"]; ?></td>
                <td><?php echo $arr[$i]["money"]; ?></td>
                <td><?php echo $arr[$i]["create_time"][0]; ?></td>
                <td><button class="btn btn-primary withdraw" data-toggle="modal" onclick="getMsg(<?php echo $arr[$i]["id"][0]; ?>)" data-target="#withdrawDone">确认</button></td>
            </tr>
            <?php } ?>
        </table>

    </div>
</div>
<?php
dialogHeader("withdrawDone", "", "提现确认","sm"); ?>
<div id="withdrawInfo" class="modal-body"></div>
<input id="withdrawInput" type="text" style="display: none" name="withdrawDone">
<?php dialogFooter(1); ?>
<script>
    function getMsg(id) {
        $(".ds").css("display","inline-block")
        $("#withdrawInput").val(id)
        $.post("getMessage.php",{UpdateWithdraw:id},function (o) {
            if(o=="余额不足") {
                $(".ds").css("display","none")
            }
            $("#withdrawInfo").html(o)
        })
    }
    $(function(){
        $(".ds").click(function(){
            var id=$("#withdrawInput").val()
            location.href="?withdrawDone="+id+"#"
            return false
        })
    })
</script>
</body>
</html>
